<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>添加</title>
    <style>
        #idv{
            width: 300px;
            margin: 50px auto;
            border:1px silver solid;
        }
        form{
            margin-left: 30px;
        }
        form>div:last-child{
            width: 50px;
            margin: 0 auto;
        }
        form>div{
            margin-top: 8px;
        }
    </style>
</head>
<body>
    <div id="idv">
        <form action="AddServlet" method="get" onsubmit="return fun(this)">
            <div>姓名：<input type="text" name="name" placeholder="这里填写姓名" required/></div>
            <div>
                性别：<input type="radio" name="sex" class="nn" value="男" checked/>男
                <input type="radio" name="sex" class="nn" value="女"/>女
            </div>
            <div>年龄：<input type="text" name="age" placeholder="这里填写年龄" required/></div>
            <div>
                日期：<input type="date" name="birthday" required/>
            </div>
            <div><input type="submit" value="提交"/></div>
        </form>
    </div>

</body>
<script>
        //验证年龄参数值
        function fun(form){
            if(form.age.value>100||form.age.value<0){
                alert("请输入0~100的合法年龄！");
                form.age.focus();
                return false;
            }
            return true;
        };
</script>
</html>